<%@ page language="java" import="java.util.*, com.mstore.pojo.Account"
	pageEncoding="utf-8"%>
<%
	Object object = request.getSession().getAttribute("account");
	Account account = null;
	if (object != null) {
		account = (Account) object;
	} else {
		account = new Account();
	}
%>
<div class="navbar navbar-default" id="navbar">
	<div class="navbar-container" id="navbar-container">
		<div class="navbar-header pull-left">
			<div class="navbar-brand">
				<small>MICRM系统企业管理平台</small>
			</div>
			<!-- /.brand -->
		</div>

		<div class="navbar-header pull-right" role="navigation">
			<ul class="nav ace-nav">
				<li class="purple">
					<a data-toggle="dropdown"
						class="dropdown-toggle" href="#">
						<i class="icon-bell-alt icon-animated-bell"></i>
					 	<span class="badge badge-important">0</span>
					</a>
					<ul class="pull-right dropdown-navbar navbar-pink dropdown-menu dropdown-caret dropdown-close my-ul">
					</ul>
				</li>
				<li class="light-blue"><a data-toggle="dropdown" href="#"
					class="dropdown-toggle"> <img class="nav-user-photo"
						src="${pageContext.request.contextPath}/assets/avatars/logo.jpg" alt="admin's Photo" /> <span
						class="user-info"> <small>欢迎,</small> <%=account.getName()%>
					</span> <i class="icon-caret-down"></i> </a>
					<ul
						class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
						<li><a href="maccount!selectAccountToUpdate?qyAuthority=yes"><i
								class="icon-edit"></i>企业基本信息</a></li>
						<li><a href="maccount!findAccount"><i class="icon-edit"></i>企业密码管理</a>
						</li>
						<li><a href="member!logout"><i class="icon-off"></i>退出</a></li>
					</ul></li>
			</ul>
		</div>
	</div>
</div>

<script type="text/javascript">
	function readApplicationForConcume() {
		$.ajax( {
			url : "noticeaction!modifyReadStatus",
			type : "post",
			data : {"type" : 1},
			datatype : "json",
			success : function(data) {
				var d = eval("(" + data + ")");
				if (d.temp = 'ok') {
					$.post("bApplication!accountAuditorSelect?passType=4");
					window.location.href= "bApplication!accountAuditorSelect?passType=4";
				}
			},
			error : function(request) {
				alert("Connection error");
			}
		});
	}
	
	function readApplicationForBalance() {
		$.ajax( {
			url : "noticeaction!modifyReadStatus",
			type : "post",
			data : {"type" : 2},
			datatype : "json",
			success : function(data) {
				var d = eval("(" + data + ")");
				if (d.temp == 'ok') {
					window.location.href= "bApplication!accountAuditorSelectBalance?passType=4";
				}
			},
			error : function(request) {
				alert("Connection error");
			}
		});
	}
	
	function getNotices() {
		$.ajax( {
			url : "noticeaction!searchEaNotices",
			type : "post",
			datatype : "json",
			success : function(data) {
				var d = eval("(" + data + ")");
				$(".badge-important").html(d.length);
				if (d.length > 0) {
					$(".my-ul").html("");
					$(".my-ul").append("<li class='dropdown-header'><i class='icon-warning-sign'></i>" + d.length + " 新条消息</li>");
					for ( var i = 0; i < d.length; i++) {
						if (d[i].type == 1) {
							$(".my-ul").append("<li><a href='javascript:void(0);' onclick='javascript:readApplicationForConcume();'><div class='clearfix'><span class='pull-left'><i class='btn btn-xs no-hover btn-pink icon-external-link'></i>"+ d[i].count + " 条消费退换申请</div></a></li>");
						}else if(d[i].type == 2) {
							$(".my-ul").append("<li><a href='javascript:void(0);' onclick='javascript:readApplicationForBalance();'><div class='clearfix'><span class='pull-left'><i class='btn btn-xs btn-primary icon-eye-open'></i>"+ d[i].count + " 条充值退换申请</div></a></li>");
						}
					}
				}else {
					$(".my-ul").html("");
					$(".my-ul").append("<li class='dropdown-header'>无消息</li>");
				}
			},
			error : function(request) {
				alert("Connection error");
			}
		});
	}
	
	getNotices();
	setInterval("getNotices()",180000);
</script>
